#include <stdio.h>

void toDegreesMinutesAndSeconds(double n, int *degrees,int *minutes, double *seconds);

int main() {
	double n, seconds;
	int degrees, minutes;
	
	printf("Enter longitude in decimal degrees [0 to 180]:\n");
	scanf("%lf", &n);
	if(n<0||n>180)
		printf("Error: invalid input");
	else {
	toDegreesMinutesAndSeconds(n, &degrees,&minutes, &seconds);
	printf("the longitude in degrees, minutes, seconds : %d , %d , %f", degrees, minutes, seconds);	
	}

	return 0;
}

void toDegreesMinutesAndSeconds(double n, int *degrees,int *minutes, double *seconds){
	*degrees = n;
	*minutes = (n - *degrees) * 60;
	*seconds = (n - *degrees - *minutes / 60.0) * 60*60;
}
